sub getDOY 
{
    my ($day, $mon, $year) = split /-/, $_[0];
    my ($hour, $mins) = split /:/, $_[1];

    $leap = int (1 - (($year - int(($year)/4) * 4) / 4)) ;
    if ($year < 100)               # ... this will only work for 94 years!
    {
        $year += 2000;
    }

    if ($day > 31)                 # ... an attempt to catch people entering
    {                              #     incorrect dates
        $doy = -1;
    }
    elsif ($mon == 1 || $mon =~ /jan/i)
    {
        $doy = $day;
    }
    elsif ($mon == 2 || $mon =~ /feb/i)
    {
        $doy = 31+$day;
    }
    elsif ($mon == 3 || $mon =~ /mar/i)
    {
        $doy = 59+$leap+$day;
    }
    elsif ($mon == 4 || $mon =~ /apr/i)
    {
        $doy = 90+$leap+$day;
    }
    elsif ($mon == 5 || $mon =~ /may/i)
    {
        $doy = 120+$leap+$day;
    }
    elsif ($mon == 6 || $mon =~ /jun/i)
    {
        $doy = 151+$leap+$day;
    }
    elsif ($mon == 7 || $mon =~ /jul/i)
    {
        $doy = 181+$leap+$day;
    }
        elsif ($mon == 8 || $mon =~ /aug/i)
    { 
        $doy = 212+$leap+$day;
    }
    elsif ($mon == 9 || $mon =~ /sep/i)
    {
        $doy = 243+$leap+$day;
    }
    elsif ($mon == 10 || $mon =~ /oct/i)
    {
        $doy = 273+$leap+$day;
    }
    elsif ($mon == 11 || $mon =~ /nov/i)
    {
        $doy = 304+$leap+$day;
    }
    elsif ($mon == 12 || $mon =~ /dec/i)
    {
        $doy = 334+$leap+$day;
    }
    else 
    {
        $doy = -1
    }

    my ($p1, $p2, $p3, $p4, $p4, $thisYear, $p6, $p7, $p8) = localtime();
    $thisYear += 1900;

    if ($doy >= 0)
    {
        $doy += (($mins / 60) + $hour) / 24;
        $doy += (($year - $thisYear) * 366);         # ... should handle next year (or the year after!)
    }
    return $doy;
}
1;

sub parsDate
{
    my ($p0, $p1, $p2, $p3);
    $p0 = 1;

    my ($day, $mon, $year) = split /-/, $_[0];
    if ($year < 100)               # ... this will only work for 94 years!
    {
        $year += 2000;
    }
    $p3 = $year;

    if ($day == 1)
    {
        $p1 = "1st";
    }
    elsif ($day == 2)
    {
        $p1 = "2nd";
    }
    elsif ($day == 3)
    {
        $p1 = "3rd";
    }
    elsif ($day == 4)
    {
        $p1 = "4th";
    }
    elsif ($day == 5)
    {
        $p1 = "5th";
    }
    elsif ($day == 6)
    {
        $p1 = "6th";
    }
    elsif ($day == 7)
    {
        $p1 = "7th";
    }
    elsif ($day == 8)
    {
        $p1 = "8th";
    }
    elsif ($day == 9)
    {
        $p1 = "9th";
    }
    elsif ($day == 10)
    {
        $p1 = "10th";
    }
    elsif ($day == 11)
    {
        $p1 = "11th";
    }
    elsif ($day == 12)
    {
        $p1 = "12th";
    }
    elsif ($day == 13)
    {
        $p1 = "13th";
    }
    elsif ($day == 14)
    {
        $p1 = "14th";
    }
    elsif ($day == 15)
    {
        $p1 = "15th";
    }
    elsif ($day == 16)
    {
        $p1 = "16th";
    }
    elsif ($day == 17)
    {
        $p1 = "17th";
    }
    elsif ($day == 18)
    {
        $p1 = "18th";
    }
    elsif ($day == 19)
    {
        $p1 = "19th";
    }
    elsif ($day == 20)
    {
        $p1 = "20th";
    }
    elsif ($day == 21)
    {
        $p1 = "21st";
   }
    elsif ($day == 22)
    {
        $p1 = "22nd";
    }
    elsif ($day == 23)
    {
        $p1 = "23rd";
    }
    elsif ($day == 24)
    {
        $p1 = "24th";
    }
    elsif ($day == 25)
    {
        $p1 = "25th";
    }
    elsif ($day == 26)
    {
        $p1 = "26th";
    }
    elsif ($day == 27)
    {
        $p1 = "27th";
    }
    elsif ($day == 28)
    {
        $p1 = "28th";
    }
    elsif ($day == 29)
    {
        $p1 = "29th";
    }
    elsif ($day == 30)
    {
        $p1 = "30th";
    }
    elsif ($day == 31)
    {
        $p1 = "31st";
    }
    else
    {
        $p0 = 0;
    }

    if ($mon == 1 || $mon =~ /jan/i)
    {
        $p2 = "January";
    }
    elsif ($mon == 2 || $mon =~ /feb/i)
    {
        $p2 = "February";
    }
    elsif ($mon == 3 || $mon =~ /mar/i)
    {
        $p2 = "March";
    }
    elsif ($mon == 4 || $mon =~ /apr/i)
    {
       $p2 = "April";
    }
    elsif ($mon == 5 || $mon =~ /may/i)
    {
        $p2 = "May";
    }
    elsif ($mon == 6 || $mon =~ /jun/i)
    {
        $p2 = "Jun";
    }
    elsif ($mon == 7 || $mon =~ /jul/i)
    {
        $p2 = "July";
    }
    elsif ($mon == 8 || $mon =~ /aug/i)
    { 
        $p2 = "August";
    }
    elsif ($mon == 9 || $mon =~ /sep/i)
    {
        $p2 = "September";
    }
    elsif ($mon == 10 || $mon =~ /oct/i)
    {
        $p2 = "October";
    }
    elsif ($mon == 11 || $mon =~ /nov/i)
    {
        $p2 = "November";
    }
    elsif ($mon == 12 || $mon =~ /dec/i)
    {
        $p2 = "December";
    }
    else 
    {
        $p0 = 0;
    }
    return ($p0, $p1, $p2, $p3);
}
1;

sub fmtDate 
{
    my ($day, $mon, $year) = split /-/, $_[0];

    if ($year < 100)               # ... this will only work for 94 years!
    {
        $year += 2000;
    }

    if ($day < 10)
    {
        $day = "0".$day;
    }

    if ($mon == 1 || $mon =~ /jan/i)
    {
        $dateStr = $day . "-01-" . $year;
    }
    elsif ($mon == 2 || $mon =~ /feb/i)
    {
        $dateStr = $day . "-02-" . $year;
    }
    elsif ($mon == 3 || $mon =~ /mar/i)
    {
        $dateStr = $day . "-03-" . $year;
    }
    elsif ($mon == 4 || $mon =~ /apr/i)
    {
        $dateStr = $day . "-04-" . $year;
    }
    elsif ($mon == 5 || $mon =~ /may/i)
    {
        $dateStr = $day . "-05-" . $year;
    }
    elsif ($mon == 6 || $mon =~ /jun/i)
    {
        $dateStr = $day . "-06-" . $year;
    }
    elsif ($mon == 7 || $mon =~ /jul/i)
    {
        $dateStr = $day . "-07-" . $year;
    }
        elsif ($mon == 8 || $mon =~ /aug/i)
    { 
        $dateStr = $day . "-08-" . $year;
    }
    elsif ($mon == 9 || $mon =~ /sep/i)
    {
        $dateStr = $day . "-09-" . $year;
    }
    elsif ($mon == 10 || $mon =~ /oct/i)
    {
        $dateStr = $day . "-10-" . $year;
    }
    elsif ($mon == 11 || $mon =~ /nov/i)
    {
        $dateStr = $day . "-11-" . $year;
    }
    elsif ($mon == 12 || $mon =~ /dec/i)
    {
        $dateStr = $day . "-12-" . $year;
    }

    return $dateStr;
}
1;







